home *** CD-ROM | disk | FTP | other *** search
- /*
- * createfile.c
- *
- * a little program to create files for use with fdev.device
- * (this is quite slow, should really use larger buffer...)
- *
- *
- * Written by Timo Rossi, completely Public Domain.
- *
- * Usage: createfile <filename> <numblocks>
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
-
- #define BLOCKSIZE 512
-
- void main(int argc, char *argv[])
- {
- int i, numblocks;
- FILE *fp;
- static char block[BLOCKSIZE];
-
- if(argc!=3)
- {
- usage:
- printf("Usage: %s <filename> <numblocks>\n", argv[0]);
- exit(10);
- }
-
- if((numblocks=atoi(argv[2]))<=0) goto usage;
-
- if((fp=fopen(argv[1], "w"))==NULL)
- {
- printf("Can't create file '%s'\n", argv[1]);
- exit(10);
- }
-
- printf("Creating '%s' -- %d blocks, %d bytes\n",
- argv[1], numblocks, numblocks*BLOCKSIZE);
-
- for(i=0; i<numblocks; i++)
- fwrite(block, BLOCKSIZE, 1, fp);
- fclose(fp);
- }
-